package cn.leve.web.utils.servlet;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author Wang Weiwei
 * @Since 16-10-27
 * @Describe
 * HttpRequest请求工具类
 */
public class HttpRequestUtils {

    /**@param request HttpServletRequest对象
     *
     * @return 该项目的网络根地址 以url的形式返回
     *          如:  http://localhost:8080/market
     *
     * @describe 获取项目在网络上的url的根地址,包括网络协议,主机名,端口以及工程名
     * */
    public static String basePath(HttpServletRequest request){
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
                + path;
        return basePath;
    }
}
